import { app } from "electron";
import path from "node:path";
import fs from "node:fs";
import { s } from "vite/dist/node/types.d-aGj9QkWt";
export function writeWindowsBound(obj: any) {
    const userDataPath = app.getPath("userData");
    const settingsFilePath = path.join(userDataPath, "windowBounds.json");
    const json = JSON.stringify(obj);
    fs.writeFileSync(settingsFilePath, json);
}

export function readWindowsBound(name: string) {
    const userDataPath = app.getPath("userData");
    const settingsFilePath = path.join(userDataPath, "windowBounds.json");
    let isExits = fs.existsSync(settingsFilePath);
    if (!isExits) {
        return null;
    }
    let str = fs.readFileSync(settingsFilePath, { encoding: "utf8" });
    if (str) {
        str = str.toString();
        let obj = JSON.parse(JSON.parse(str));
        return obj[name];
    }
    return null;
}
